package com.xumz.dao.impl;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;
import com.xumz.dao.ClassDao;
import com.xumz.model.ClassName;
import com.xumz.model.StudentManage;
@Repository
public class ClassDaoImpl extends SqlSessionDaoSupport implements ClassDao {
	@Override
	public List<StudentManage> selectAll() {
		List<StudentManage> list = this.getSqlSession().selectList("findAllStuMessage");
		return list;
	}
	
	@Override
	public List<StudentManage> selectAllByTeacherId(String id) {
		List<StudentManage> list = this.getSqlSession().selectList("findAllStuMessageByTeacherId",id);
		return list;
	}
	
	@Override
	public List<ClassName> selectClassName(){
		List<ClassName> list = this.getSqlSession().selectList("findAllClass");
		return list;
	}
	
	@Override
	public List<ClassName> selectClassNameByTeacherId(String id) {
		List<ClassName> list = this.getSqlSession().selectList("findAllClassByTeacherId",id);
		return list;
	}
	
	@Override
	public int classgroupAdd(String classId,String classname, String classdescribe){
		
		ClassName classgroup = new ClassName(classId,classname,classdescribe);
		return this.getSqlSession().insert(this.getClass().getName() + ".classgroupAdd", classgroup);
	}
	
	@Override
	public int classgroupUpdate(ClassName classname){
		return this.getSqlSession().update(this.getClass().getName() + ".classgroupUpdate", classname);
	}
	
	@Override
	public int classgroupDelete(String classId){
		this.getSqlSession().delete(this.getClass().getName() + ".studentDelete", classId);
		this.getSqlSession().delete(this.getClass().getName() + ".classSettingDelete", classId);
		return this.getSqlSession().delete(this.getClass().getName() + ".classgroupDelete", classId);
	}

	@Override
	public ClassName selectOne(String id) {
		ClassName classname = this.getSqlSession().selectOne(this.getClass().getName() + ".findClassNameById",id);
		return classname;
	}
	
}
